home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
nn.zip
/
ACTIVE.C
next >
Wrap
C/C++ Source or Header
|
1989-06-28
|
2KB
|
87 lines
/*
* read/update incore copy of active file
*/
#include "config.h"
#ifdef NNTP
char news_active[FILENAME];
#else
char news_active[] = NEWS_ACTIVE;
#endif
visit_active_file()
{
FILE *act;
char line[512];
register char *cp, *name;
register group_header *gh;
group_header *add_new_group();
#ifdef NNTP
FILE *nntp_act;
nntp_act = NULL;
if (use_nntp)
nntp_get_active();
else
if (is_master) /* copy 'active' to DB/ACTIVE */
nntp_act = open_file(relative(db_directory, "ACTIVE"), OPEN_CREATE | MUST_EXIST);
#endif
act = open_file(news_active, OPEN_READ|MUST_EXIST);
while (fgets(line, 512, act)) {
#ifdef NNTP
if (nntp_act != NULL)
fputs(line, nntp_act);
#endif
cp = line;
while (*cp && isspace(*cp)) cp++; /* eat blank lines */
if (*cp == NUL || *cp == '#') continue;
/* cp -> NAME space 00888 ... nl */
name = cp;
while (*cp != ' ') cp++;
*cp++ = NUL;
gh = lookup(name);
if (gh == NULL) {
/* new group */
gh = add_new_group(name);
if (gh == NULL) continue;
}
while (*cp && isspace(*cp)) cp++;
gh->last_article = atol(cp);
while (*cp && isdigit(*cp)) cp++;
while (*cp && isspace(*cp)) cp++;
if (*cp == NUL) {
log_entry('E', "Error in active file for entry %s", name);
continue;
}
gh->first_article = atol(cp);
if (gh->first_article == 0) gh->first_article = 1;
while (*cp && isdigit(*cp)) cp++;
while (*cp && isspace(*cp)) cp++;
if (*cp == NUL) continue;
if (*cp == 'm')
gh->group_flag |= G_MODERATED;
else
gh->group_flag &= ~G_MODERATED;
}
fclose(act);
#ifdef NNTP
if (nntp_act != NULL)
fclose(nntp_act);
#endif
}